import {
  q as o,
  p as O,
  ap as T,
  X as y,
  f as V,
  H as F,
  av as b,
  aw as H,
  az as P,
  as as i,
  aG as j,
  at as f
} from "./index-30f27935.js";
import { f as x } from "./finance-301595de.js";
function X(w) {
  const u = o([]),
    s = o(!0);
  o({}), O();
  const m = o(1),
    d = o(10),
    t = o([]),
    v = o(""),
    S = T("reload"),
    p = y({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    B = y({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    C = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      {
        label: "库存",
        prop: "count",
        minWidth: 100,
        formatter: ({ count: e, symbol: a }) => a + " " + e
      },
      { label: "备注", prop: "content", minWidth: 80 },
      { label: "创建时间", prop: "create_time", minWidth: 100 }
    ],
    _ = V(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function W(e) {
    P(e);
  }
  async function z(e) {
    const a = { role_id: e.role_id },
      l = JSON.stringify(a),
      g = { value: i.enc.Base64.stringify(i.enc.Utf8.parse(l)) },
      r = await j(g);
    r.code == 200
      ? (f("删除成功", { type: "success" }), S())
      : f(r.msg, { type: "error" });
  }
  function D() {}
  function I(e) {
    (d.value = e), h(void 0, e);
  }
  function J(e) {
    (m.value = e), h(e, void 0);
  }
  function L(e) {}
  function U(e) {
    (B.text = `正在加载第${e}页...`),
      (s.value = !0),
      b(600).then(() => {
        s.value = !1;
      });
  }
  async function k(e, a = []) {
    (t.value = []),
      (s.value = !0),
      (v.value = e.user_phone),
      a.map(N => {
        const R = N,
          A = new Date(R);
        t.value.push(
          A.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      });
    const l = {
        page: 1,
        pagesize: d.value,
        content: "count",
        user_phone: e.user_phone,
        type: e.type,
        start: t.value[0],
        end: t.value[1]
      },
      c = JSON.stringify(l),
      r = { value: i.enc.Base64.stringify(i.enc.Utf8.parse(c)) },
      { data: n } = await x(r);
    (u.value = n.count.data),
      (p.total = n.count.total),
      setTimeout(() => {
        s.value = !1;
      }, 500);
  }
  async function h(e = m.value, a = d.value) {
    const l = {
        page: e,
        pagesize: a,
        user_phone: v.value,
        start: t.value[0],
        end: t.value[1],
        content: "count"
      },
      c = JSON.stringify(l),
      r = { value: i.enc.Base64.stringify(i.enc.Utf8.parse(c)) },
      n = await x(r);
    n.code === 200
      ? ((u.value = n.data.count.data),
        (p.total = n.data.count.total),
        setTimeout(() => {
          s.value = !1;
        }, 500))
      : f(n.msg, { type: "error" });
  }
  const M = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    F(() => {
      b().then(() => {
        const { setWatermark: e } = H(w.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        h();
    }),
    {
      loading: s,
      columns: C,
      dataList: u,
      pagination: p,
      buttonClass: _,
      formattedDate: t,
      onSearch: k,
      resetForm: M,
      handleaddUser: D,
      handleUpdate: W,
      handleDelete: z,
      handleSizeChange: I,
      handleCurrentChange: J,
      handleSelectionChange: L,
      onCurrentChange: U
    }
  );
}
export { X as useRole };
